/*
 * FavorableMessageHolder.java
 * business
 *
 * Created by ChenTao on 2017/1/9.
 *
 * Copyright (c) 2017年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.widget.listview.viewholder;

import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.yidiandao.business.R;
import com.yidiandao.business.ui.widget.listview.ViewHolder;
import com.yidiandao.business.utils.ImageLoader;

/**
 * 优惠促销-ViewHolder
 */
public class FavorableMessageHolder extends ViewHolder {

    public RelativeLayout rootLayout;

    private ImageView ivImage;

    private TextView tvTitle;

    private TextView tvContent;

    public TextView tvUnreadCount;

    @Override
    protected void initView(View rootView) {

        tvUnreadCount = (TextView) rootView.findViewById(R.id.tv_unread_count);
        ivImage = (ImageView) rootView.findViewById(R.id.iv_image);
        tvTitle = (TextView) rootView.findViewById(R.id.tv_title);
        tvContent = (TextView) rootView.findViewById(R.id.tv_content);
        rootLayout = (RelativeLayout) rootView.findViewById(R.id.root_layout);

        initFavorableMessageUI();
    }

    private void initFavorableMessageUI() {
        ImageLoader.loadLocalImage(mContext, ivImage, R.mipmap.ic_favorable_message);
        tvTitle.setText(R.string.favorable_message);
        tvContent.setText(R.string.click_to_show_favourable_messages);
    }

    public void refreshUnReadCount(int unReadCount) {
        if (unReadCount <= 0) {
            tvUnreadCount.setVisibility(View.GONE);
            return;
        }

        tvUnreadCount.setVisibility(View.VISIBLE);
        if (unReadCount <= 99) {
            tvUnreadCount.setText(unReadCount + "");
            return;
        }

        tvUnreadCount.setText(R.string.more_message);
    }

    @Override
    protected int getItemLayoutId() {
        return R.layout.item_message_count;
    }
}
